<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>digichef.profiles.utils</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="digichef-module.html">Package&nbsp;digichef</a> ::
        <a href="digichef.profiles-module.html">Package&nbsp;profiles</a> ::
        Module&nbsp;utils
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="digichef.profiles.utils-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="digichef.profiles.utils-module.html">Module digichef.profiles.utils</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno"> 1</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno"> 2</tt>  <tt class="py-line"><tt class="py-docstring">Utility functions for retrieving and generating forms for the</tt> </tt>
<a name="L3"></a><tt class="py-lineno"> 3</tt>  <tt class="py-line"><tt class="py-docstring">site-specific user profile model specified in the</tt> </tt>
<a name="L4"></a><tt class="py-lineno"> 4</tt>  <tt class="py-line"><tt class="py-docstring">``AUTH_PROFILE_MODULE`` setting.</tt> </tt>
<a name="L5"></a><tt class="py-lineno"> 5</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L6"></a><tt class="py-lineno"> 6</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L7"></a><tt class="py-lineno"> 7</tt>  <tt class="py-line"> </tt>
<a name="L8"></a><tt class="py-lineno"> 8</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">django</tt> <tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Module digichef.profiles.forms=digichef.profiles.forms-module.html,Module digichef.recipes.forms=digichef.recipes.forms-module.html,Module digichef.registration.forms=digichef.registration.forms-module.html,Module digichef.tagging.forms=digichef.tagging.forms-module.html"><a title="digichef.profiles.forms
digichef.recipes.forms
digichef.registration.forms
digichef.tagging.forms" class="py-name" href="#" onclick="return doclink('link-0', 'forms', 'link-0');">forms</a></tt> </tt>
<a name="L9"></a><tt class="py-lineno"> 9</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">django</tt><tt class="py-op">.</tt><tt class="py-name">conf</tt> <tt class="py-keyword">import</tt> <tt id="link-1" class="py-name" targets="Module digichef.settings=digichef.settings-module.html,Module digichef.tagging.settings=digichef.tagging.settings-module.html,Module digichef.tagging.tests.settings=digichef.tagging.tests.settings-module.html,Module digichef.voting.tests.settings=digichef.voting.tests.settings-module.html"><a title="digichef.settings
digichef.tagging.settings
digichef.tagging.tests.settings
digichef.voting.tests.settings" class="py-name" href="#" onclick="return doclink('link-1', 'settings', 'link-1');">settings</a></tt> </tt>
<a name="L10"></a><tt class="py-lineno">10</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">django</tt><tt class="py-op">.</tt><tt class="py-name">db</tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Module digichef.core.models=digichef.core.models-module.html,Module digichef.profiles.models=digichef.profiles.models-module.html,Module digichef.recipes.models=digichef.recipes.models-module.html,Module digichef.recommender.models=digichef.recommender.models-module.html,Module digichef.registration.models=digichef.registration.models-module.html,Module digichef.tagging.models=digichef.tagging.models-module.html,Module digichef.tagging.tests.models=digichef.tagging.tests.models-module.html,Module digichef.util.models=digichef.util.models-module.html,Module digichef.voting.models=digichef.voting.models-module.html,Module digichef.voting.tests.models=digichef.voting.tests.models-module.html"><a title="digichef.core.models
digichef.profiles.models
digichef.recipes.models
digichef.recommender.models
digichef.registration.models
digichef.tagging.models
digichef.tagging.tests.models
digichef.util.models
digichef.voting.models
digichef.voting.tests.models" class="py-name" href="#" onclick="return doclink('link-2', 'models', 'link-2');">models</a></tt> <tt class="py-keyword">import</tt> <tt class="py-name">get_model</tt> </tt>
<a name="L11"></a><tt class="py-lineno">11</tt>  <tt class="py-line"> </tt>
<a name="L12"></a><tt class="py-lineno">12</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">django</tt><tt class="py-op">.</tt><tt class="py-name">contrib</tt><tt class="py-op">.</tt><tt class="py-name">auth</tt><tt class="py-op">.</tt><tt id="link-3" class="py-name"><a title="digichef.core.models
digichef.profiles.models
digichef.recipes.models
digichef.recommender.models
digichef.registration.models
digichef.tagging.models
digichef.tagging.tests.models
digichef.util.models
digichef.voting.models
digichef.voting.tests.models" class="py-name" href="#" onclick="return doclink('link-3', 'models', 'link-2');">models</a></tt> <tt class="py-keyword">import</tt> <tt class="py-name">SiteProfileNotAvailable</tt> </tt>
<a name="L13"></a><tt class="py-lineno">13</tt>  <tt class="py-line"> </tt>
<a name="L14"></a><tt class="py-lineno">14</tt>  <tt class="py-line"> </tt>
<a name="get_profile_model"></a><div id="get_profile_model-def"><a name="L15"></a><tt class="py-lineno">15</tt> <a class="py-toggle" href="#" id="get_profile_model-toggle" onclick="return toggle('get_profile_model');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="digichef.profiles.utils-module.html#get_profile_model">get_profile_model</a><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="get_profile_model-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="get_profile_model-expanded"><a name="L16"></a><tt class="py-lineno">16</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L17"></a><tt class="py-lineno">17</tt>  <tt class="py-line"><tt class="py-docstring">    Return the model class for the currently-active user profile</tt> </tt>
<a name="L18"></a><tt class="py-lineno">18</tt>  <tt class="py-line"><tt class="py-docstring">    model, as defined by the ``AUTH_PROFILE_MODULE`` setting. If that</tt> </tt>
<a name="L19"></a><tt class="py-lineno">19</tt>  <tt class="py-line"><tt class="py-docstring">    setting is missing, raise</tt> </tt>
<a name="L20"></a><tt class="py-lineno">20</tt>  <tt class="py-line"><tt class="py-docstring">    ``django.contrib.auth.models.SiteProfileNotAvailable``.</tt> </tt>
<a name="L21"></a><tt class="py-lineno">21</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L22"></a><tt class="py-lineno">22</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L23"></a><tt class="py-lineno">23</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-op">(</tt><tt class="py-keyword">not</tt> <tt class="py-name">hasattr</tt><tt class="py-op">(</tt><tt id="link-4" class="py-name"><a title="digichef.settings
digichef.tagging.settings
digichef.tagging.tests.settings
digichef.voting.tests.settings" class="py-name" href="#" onclick="return doclink('link-4', 'settings', 'link-1');">settings</a></tt><tt class="py-op">,</tt> <tt class="py-string">'AUTH_PROFILE_MODULE'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> <tt class="py-keyword">or</tt> \ </tt>
<a name="L24"></a><tt class="py-lineno">24</tt>  <tt class="py-line">           <tt class="py-op">(</tt><tt class="py-keyword">not</tt> <tt id="link-5" class="py-name"><a title="digichef.settings
digichef.tagging.settings
digichef.tagging.tests.settings
digichef.voting.tests.settings" class="py-name" href="#" onclick="return doclink('link-5', 'settings', 'link-1');">settings</a></tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Variable digichef.settings.AUTH_PROFILE_MODULE=digichef.settings-module.html#AUTH_PROFILE_MODULE"><a title="digichef.settings.AUTH_PROFILE_MODULE" class="py-name" href="#" onclick="return doclink('link-6', 'AUTH_PROFILE_MODULE', 'link-6');">AUTH_PROFILE_MODULE</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L25"></a><tt class="py-lineno">25</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">SiteProfileNotAvailable</tt> </tt>
<a name="L26"></a><tt class="py-lineno">26</tt>  <tt class="py-line">    <tt class="py-name">profile_mod</tt> <tt class="py-op">=</tt> <tt class="py-name">get_model</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt id="link-7" class="py-name"><a title="digichef.settings
digichef.tagging.settings
digichef.tagging.tests.settings
digichef.voting.tests.settings" class="py-name" href="#" onclick="return doclink('link-7', 'settings', 'link-1');">settings</a></tt><tt class="py-op">.</tt><tt id="link-8" class="py-name"><a title="digichef.settings.AUTH_PROFILE_MODULE" class="py-name" href="#" onclick="return doclink('link-8', 'AUTH_PROFILE_MODULE', 'link-6');">AUTH_PROFILE_MODULE</a></tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Function re.split()=re-module.html#split"><a title="re.split" class="py-name" href="#" onclick="return doclink('link-9', 'split', 'link-9');">split</a></tt><tt class="py-op">(</tt><tt class="py-string">'.'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L27"></a><tt class="py-lineno">27</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">profile_mod</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L28"></a><tt class="py-lineno">28</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">SiteProfileNotAvailable</tt> </tt>
<a name="L29"></a><tt class="py-lineno">29</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">profile_mod</tt> </tt>
</div><a name="L30"></a><tt class="py-lineno">30</tt>  <tt class="py-line"> </tt>
<a name="L31"></a><tt class="py-lineno">31</tt>  <tt class="py-line"> </tt>
<a name="get_profile_form"></a><div id="get_profile_form-def"><a name="L32"></a><tt class="py-lineno">32</tt> <a class="py-toggle" href="#" id="get_profile_form-toggle" onclick="return toggle('get_profile_form');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="digichef.profiles.utils-module.html#get_profile_form">get_profile_form</a><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="get_profile_form-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="get_profile_form-expanded"><a name="L33"></a><tt class="py-lineno">33</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L34"></a><tt class="py-lineno">34</tt>  <tt class="py-line"><tt class="py-docstring">    Return a form class (a subclass of the default ``ModelForm``)</tt> </tt>
<a name="L35"></a><tt class="py-lineno">35</tt>  <tt class="py-line"><tt class="py-docstring">    suitable for creating/editing instances of the site-specific user</tt> </tt>
<a name="L36"></a><tt class="py-lineno">36</tt>  <tt class="py-line"><tt class="py-docstring">    profile model, as defined by the ``AUTH_PROFILE_MODULE``</tt> </tt>
<a name="L37"></a><tt class="py-lineno">37</tt>  <tt class="py-line"><tt class="py-docstring">    setting. If that setting is missing, raise</tt> </tt>
<a name="L38"></a><tt class="py-lineno">38</tt>  <tt class="py-line"><tt class="py-docstring">    ``django.contrib.auth.models.SiteProfileNotAvailable``.</tt> </tt>
<a name="L39"></a><tt class="py-lineno">39</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L40"></a><tt class="py-lineno">40</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L41"></a><tt class="py-lineno">41</tt>  <tt class="py-line">    <tt class="py-name">profile_mod</tt> <tt class="py-op">=</tt> <tt id="link-10" class="py-name" targets="Function digichef.profiles.utils.get_profile_model()=digichef.profiles.utils-module.html#get_profile_model"><a title="digichef.profiles.utils.get_profile_model" class="py-name" href="#" onclick="return doclink('link-10', 'get_profile_model', 'link-10');">get_profile_model</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L42"></a><tt class="py-lineno">42</tt>  <tt class="py-line">    <tt class="py-keyword">class</tt> <tt class="py-def-name">_ProfileForm</tt><tt class="py-op">(</tt><tt class="py-base-class">forms</tt><tt class="py-op">.</tt><tt class="py-base-class">ModelForm</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L43"></a><tt class="py-lineno">43</tt>  <tt class="py-line">        <tt class="py-keyword">class</tt> <tt class="py-def-name">Meta</tt><tt class="py-op">:</tt> </tt>
<a name="L44"></a><tt class="py-lineno">44</tt>  <tt class="py-line">            <tt id="link-11" class="py-name" targets="Variable digichef.profiles.forms.ProfileForm.Meta.model=digichef.profiles.forms.ProfileForm.Meta-class.html#model,Variable digichef.tagging.forms.TagAdminForm.Meta.model=digichef.tagging.forms.TagAdminForm.Meta-class.html#model"><a title="digichef.profiles.forms.ProfileForm.Meta.model
digichef.tagging.forms.TagAdminForm.Meta.model" class="py-name" href="#" onclick="return doclink('link-11', 'model', 'link-11');">model</a></tt> <tt class="py-op">=</tt> <tt class="py-name">profile_mod</tt> </tt>
<a name="L45"></a><tt class="py-lineno">45</tt>  <tt class="py-line">            <tt id="link-12" class="py-name" targets="Variable digichef.profiles.forms.ProfileForm.Meta.exclude=digichef.profiles.forms.ProfileForm.Meta-class.html#exclude"><a title="digichef.profiles.forms.ProfileForm.Meta.exclude" class="py-name" href="#" onclick="return doclink('link-12', 'exclude', 'link-12');">exclude</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-string">'user'</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> <tt class="py-comment"># User will be filled in by the view.</tt> </tt>
</div></div><a name="L46"></a><tt class="py-lineno">46</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">_ProfileForm</tt> </tt>
</div><a name="L47"></a><tt class="py-lineno">47</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Thu Apr  1 02:28:32 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
